package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.myEnum.ErrorCode;
import org.example.response.ApiResponse;
import org.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/pay")
public class WxPayController {

    @Autowired
    private OrderService orderService;

    /**
     * 模拟支付成功
     * @param orderId 订单ID
     * @return 处理结果
     */
    @PostMapping("/mock/notify/{orderId}")
    public ApiResponse<String> mockPaySuccess(@PathVariable String orderId) {
        log.info("模拟支付成功，订单号：{}", orderId);
        try {
            orderService.mockPaySuccess(orderId);
            return ApiResponse.success("支付成功");
        } catch (Exception e) {
            log.error("处理支付失败", e);
            return ApiResponse.error(ErrorCode.PAY_FAIL.getCode(),"支付失败");
        }
    }
} 